Update Audit subscription status
This endpoint allows the end user to update the subscription status to one of two possible states: pause or resume.
URL : http://34.122.70.8/api/v1/audit/subscription/:status
Method : PUT
Auth required : YES
| Headers | Type | Description |
|---|---|---|
| api-key | string | Unique api key provided to each customer |
Permissions required : None
Params constraints
Provide info including where the service should forward the Audit Records, the maximum number of records in each payload, and the frequency for sending them.
Path Parameters:
| Key | Type | Description |
|---|---|---|
| status | string | Update status to pause or resume |
Response Body:
| Field | Type | Description |
|---|---|---|
| status | Boolean | Status of the request |
| msg | string | Response message from server |
| data | Data Object |
Data Object:
| Field | Type | Description |
|---|---|---|
| id | string | ID of the audit subscription table record |
| start_time | Date | Date and time from when Audit Records should be fetched |
| last_read_at | Data Object | Time of the last Audit Record sent via the subscription |
| endpoint_url | string | Client webhook URL where data is being sent |
| fetch_limit | string | Max number of Audit Records to be sent to client in each message |
| read_interval | Number | Interval, in seconds, between messages sent to client |
| status | string | Status of the subscription. For new subscription, the status will be 'active'. |
| createdAt | Date | Date and time subscription was created |
| updatedAt | Data Object | Date and time Subscription was last updated |
Request Example All fields must be sent.
http://34.122.70.8/api/v1/audit/subscription/pause
http://34.122.70.8/api/v1/audit/subscription/resume
Success Response
Condition : If subscription is successfully paused.
Code : 200 OK
Content example
{
"status": true,
"msg": "Subscription status updated successfully",
"data": [
{
"id": 1,
"start_time": "2022-12-25T07:03:30.000Z",
"last_read_at": null,
"endpoint_url": "http://localhost:3000/hook",
"fetch_limit": 100,
"read_interval": 60,
"status": "pause",
"createdAt": "2023-07-12T18:18:26.136Z",
"updatedAt": "2023-07-12T18:18:26.136Z"
}
]
}
Or
Condition : If subscription is successfully resumed.
Code : 200 OK
Content example
{
"status": true,
"msg": "Subscription status updated successfully",
"data": [
{
"id": 1,
"start_time": "2022-12-25T07:03:30.000Z",
"last_read_at": null,
"endpoint_url": "http://localhost:3000/hook",
"fetch_limit": 100,
"read_interval": 60,
"status": "active",
"createdAt": "2023-07-12T18:18:26.136Z",
"updatedAt": "2023-07-12T18:18:26.136Z"
}
]
}
Error Responses
Condition : If param other than pause or resume is passed.
Code : 400 Bad Request
Content :
{
"status": false,
"error_code": "BAD_DATA",
"error_msg": "Subscription status not found or invalid"
}
Or
Condition : If api-key is not passed in request header or is wrong.
Code : 401 Unauthorized
Content example
{
"status": false,
"error_code": "AUDIT_UNAUTHORIZED",
"error_msg": "Missing/MisMatch API KEY"
}
- Nodejs
- React
const fetch = require('node-fetch');
let url = 'http://34.122.70.8/api/v1/audit/subscription/resume';
let options = {method: 'PUT', headers: {'api-key': '<API_KEY>'}};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));
let headersList = {
"api-key": "<API_KEY>"
}
let response = await fetch("http://34.122.70.8/api/v1/audit/subscription/resume", {
method: "PUT",
headers: headersList
});
let data = await response.text();
console.log(data);